{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import glob\n",
    "import matplotlib.pyplot as plt\n",
    "from PIL import Image\n",
    "from multiprocessing import Pool\n",
    "from tqdm.notebook import tqdm\n",
    "\n",
    "\n",
    "def fun(idx):\n",
    "    path_imgs = [v[idx] for v in paths_imgs]\n",
    "    name = os.path.basename(path_imgs[0])\n",
    "    save_path = os.path.join(save_root,name)\n",
    "    imgs = [Image.open(v) for v in path_imgs]\n",
    "    fig = plt.figure(figsize=(len(imgs)*4,4))\n",
    "    for jdx,img in enumerate(imgs):\n",
    "        cmap = None if len(img.split())>1 else 'gray'\n",
    "        plt.subplot(1,len(imgs),jdx+1);plt.imshow(img,cmap=cmap);plt.tight_layout();plt.axis('off')\n",
    "    plt.savefig(save_path,pad_inches=0,bbox_inches='tight',transparent=True,dpi=120)\n",
    "    plt.close(fig)\n",
    "\n",
    "import sys\n",
    "paths_str = 'E:\\\\Datasets\\\\stb\\\\A,E:\\\\Datasets\\\\stb\\\\B' # python tools/together_show.py path1,path2,path3 save_root\n",
    "save_root = 'E:\\\\Datasets\\\\stb\\\\vis'\n",
    "num_workers = 3\n",
    "\n",
    "if not os.path.exists(save_root): os.mkdir(save_root)\n",
    "paths = paths_str.split(',')\n",
    "paths_imgs = [sorted(glob.glob(os.path.join(path,'*'))) for path in paths]\n",
    "length = len(paths_imgs)\n",
    "\n",
    "\n",
    "for i in tqdm(range(1000)):\n",
    "    fun(i)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
